package com.coolbi.onsupai.core.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.coolbi.onsupai.core.dao.AgentDao;
import com.coolbi.onsupai.core.entity.Agent;
import com.coolbi.onsupai.core.mapper.AgentMapper;

public class AgentDaoImpl implements AgentDao{
	@Autowired
	private AgentMapper agentMapper;
	public void setAgentMapper(AgentMapper agentMapper) {
		this.agentMapper = agentMapper;
	}

	@Override
	public Agent save(Agent obj) {
		agentMapper.save(obj);
		return obj;
	}

	@Override
	public int delete(long id) {
		return agentMapper.delete(id);
	}

	@Override
	public int update(Agent obj) {
		return agentMapper.update(obj);
	}

	@Override
	public Agent get(long id) {
		return agentMapper.get(id);
	}

	@Override
	public List<Agent> list() {
		return agentMapper.list();
	}

	@Override
	public List<Agent> listByPage(int offset, int limit) {
		Map<String,Object>parameter=new HashMap<String,Object>();
		parameter.put("offset", offset);
		parameter.put("limit",limit);
		return agentMapper.listByPage(parameter);
	}

	@Override
	public List<Agent> find(Map<String, Object> parameter) {
		return agentMapper.listByParameter(parameter);
	}

	@Override
	public List<Agent> findByPage(Map<String, Object> parameter, int offset,
			int limit) {
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return agentMapper.listByParameterPage(parameter);
	}

	@Override
	public List<Agent> search(Map<String, Object> parameter, int offset,
			int limit) {
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return agentMapper.search(parameter);
	}

	@Override
	public int count() {
		return agentMapper.count();
	}

	@Override
	public int countByKeyWord(Map<String, Object> parameter) {
		return agentMapper.countByKeyWord(parameter);
	}

	@Override
	public int count(Map<String, Object> parameter) {
		return agentMapper.countByParameter(parameter);
	}

	@Override
	public int countByTel(String tel) {
		return agentMapper.countByTel(tel);
	}

	@Override
	public int countByEmail(String email) {
		return agentMapper.countByEmail(email);
	}

	@Override
	public int countByAgentName(String agentName) {
		return agentMapper.countByAgentName(agentName);
	}

}
